<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * PHP version 5
 *
 * This source file is subject to version 2.1 of the GNU Lesser General Public
 * License, that is bundled with this package in the file COPYING, available
 * through the world wide web at the following URI:
 * http://www.gnu.org/copyleft/lesser.html.
 *
 * @package    ZNF
 * @subpackage Action
 * @author     Alessandro Rossini <http://www.alessandrorossini.org>
 * @author     Graziano Liberati <http://www.liberati.org>
 * @copyright  2004-2007 The ZNF Development Team
 * @license    LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
 * @version    SVN $Id: ActionMapping.php 43 2007-06-26 23:36:35Z aronnax $
 * @since      Release 0.5.0
 * @link       http://www.zeronotice.org
 */

/**
 * <i>ZNF_Action_ActionMapping</i> represents the informations that the controller <i>ZNF_Action_RequestProcessor</i> knows about the mapping.
 *
 * The mapping is considered from a particular request to an instance of a
 * particular <i>ZNF_Action_Action</i> class.
 *
 * The <i>ZNF_Action_ActionMapping</i> instance used to select a particular
 * <i>ZNF_Action_Action</i> is passed on to that <i>ZNF_Action_Action</i>,
 * thereby providing access to any custom configuration taken from the
 * module configuration file and included in the <i>ZNF_Action_ActionMapping</i>
 * object.
 *
 * @access     public
 * @package    ZNF
 * @subpackage Action
 * @author     Alessandro Rossini <http://www.alessandrorossini.org>
 * @author     Graziano Liberati <http://www.liberati.org>
 * @copyright  2004-2007 The ZNF Development Team
 * @license    LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
 * @version    SVN $Id: ActionMapping.php 43 2007-06-26 23:36:35Z aronnax $
 * @since      Release 0.5.0
 * @link       http://www.zeronotice.org
 */
class ZNF_Action_ActionMapping
{

    /**
     * The <i>forward</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_forward
     */
    protected $_forward = null;

    /**
     * The <i>include</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_include
     */
    protected $_include = null;

    /**
     * The <i>input</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_input
     */
    protected $_input = null;

    /**
     * The <i>name</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_name
     */
    protected $_name = null;

    /**
     * The <i>nextPath</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_nextPath
     */
    protected $_nextPath = null;

    /**
     * The <i>parameter</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_parameter
     */
    protected $_parameter = null;

    /**
     * The <i>parameterValue</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_parameterValue
     */
    protected $_parameterValue = null;

    /**
     * The <i>path</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_path
     */
    protected $_path = null;

    /**
     * The <i>roles</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_roles
     */
    protected $_roles = null;

    /**
     * The <i>scope</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_scope
     */
    protected $_scope = null;

    /**
     * The <i>type</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_type
     */
    protected $_type = null;

    /**
     * The <i>validate</i> attribute of the <i>action</i> element.
     *
     * @access protected
     * @var string $_validate
     */
    protected $_validate = null;

    /**
     * The <i>forward</i> elements of the <i>global-forwards</i> element.
     *
     * @access protected
     * @var array $_globalForwardsConfig
     */
    protected $_globalForwardsConfig = null;

    /**
     * The <i>forward</i> elements of the <i>action</i> element.
     *
     * @access protected
     * @var array $_forwardsConfig
     */
    protected $_forwardsConfig = null;

    /**
     * Constructs a new <i>ZNF_Action_ActionMapping</i> object.
     *
     * @access public
     * @param array $actionConfig
     * @param array $globalForwardsConfig
     */
    public function __construct($actionConfig, $globalForwardsConfig)
    {
        $this->setForward($actionConfig['forward']);
        $this->setInclude($actionConfig['include']);
        $this->setInput($actionConfig['input']);
        $this->setName($actionConfig['name']);
        $this->setNextPath($actionConfig['nextPath']);
        $this->setParameter($actionConfig['parameter']);
        $this->setParameterValue($actionConfig['parameterValue']);
        $this->setPath($actionConfig['path']);
        $this->setRoles($actionConfig['roles']);
        $this->setScope($actionConfig['scope']);
        $this->setType($actionConfig['type']);
        $this->setValidate($actionConfig['validate']);

        if (isset($actionConfig['forwards-config'])) {
            $this->addForwardsConfig($actionConfig['forwards-config']);
        }

        $this->addGlobalForwardsConfig($globalForwardsConfig);
    }

    /**
     * Returns the value of the <i>forward</i> property.
     *
     * @access public
     * @return string
     */
    public function getForward()
    {
        return $this->_forward;
    }

    /**
     * Sets the value of the <i>forward</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setForward($value)
    {
        $this->_forward = $value;
    }

    /**
     * Returns the value of the <i>include</i> property.
     *
     * @access public
     * @return string
     */
    public function getInclude()
    {
        return $this->_include;
    }

    /**
     * Sets the value of the <i>include</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setInclude($value)
    {
        $this->_include = $value;
    }

    /**
     * Returns the value of the <i>input</i> property.
     *
     * @access public
     * @return string
     */
    public function getInput()
    {
        return $this->_input;
    }

    /**
     * Sets the value of the <i>input</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setInput($value)
    {
        $this->_input = $value;
    }

    /**
     * Returns the value of the <i>name</i> property.
     *
     * @access public
     * @return string
     */
    public function getName()
    {
        return $this->_name;
    }

    /**
     * Sets the value of the <i>name</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setName($value)
    {
        $this->_name = $value;
    }

    /**
     * Returns the value of the <i>nextPath</i> property.
     *
     * @access public
     * @return string
     */
    public function getNextPath()
    {
        return $this->_nextPath;
    }

    /**
     * Sets the value of the <i>nextPath</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setNextPath($value)
    {
        $this->_nextPath = $value;
    }

    /**
     * Returns the value of the <i>parameter</i> property.
     *
     * @access public
     * @return string
     */
    public function getParameter()
    {
        return $this->_parameter;
    }

    /**
     * Sets the value of the <i>parameter</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setParameter($value)
    {
        $this->_parameter = $value;
    }

    /**
     * Returns the value of the <i>parameterValue</i> property.
     *
     * @access public
     * @return string
     */
    public function getParameterValue()
    {
        return $this->_parameterValue;
    }

    /**
     * Sets the value of the <i>parameterValue</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setParameterValue($value)
    {
        $this->_parameterValue = $value;
    }

    /**
     * Returns the value of the <i>path</i> property.
     *
     * @access public
     * @return string
     */
    public function getPath()
    {
        return $this->_path;
    }

    /**
     * Sets the value of the <i>path</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setPath($value)
    {
        $this->_path = $value;
    }

    /**
     * Returns the value of the <i>roles</i> property.
     *
     * @access public
     * @return string
     */
    public function getRoles()
    {
        return $this->_roles;
    }

    /**
     * Sets the value of the <i>roles</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setRoles($value)
    {
        $this->_roles = $value;
    }

    /**
     * Returns the value of the <i>scope</i> property.
     *
     * @access public
     * @return string
     */
    public function getScope()
    {
        return $this->_scope;
    }

    /**
     * Sets the value of the <i>scope</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setScope($value)
    {
        $this->_scope = $value;
    }

    /**
     * Returns the value of the <i>type</i> property.
     *
     * @access public
     * @return string
     */
    public function getType()
    {
        return $this->_type;
    }

    /**
     * Sets the value of the <i>type</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setType($value)
    {
        $this->_type = $value;
    }

    /**
     * Returns the value of the <i>validate</i> property.
     *
     * @access public
     * @return string
     */
    public function getValidate()
    {
        return $this->_validate;
    }

    /**
     * Sets the value of the <i>validate</i> property.
     *
     * @access public
     * @param string $value
     */
    public function setValidate($value)
    {
        $this->_validate = $value;
    }

    /**
     * Adds the global forwards configuration.
     *
     * @access protected
     * @param array $value
     */
    protected function addGlobalForwardsConfig($value)
    {
        $this->_globalForwardsConfig = $value;
    }

    /**
     * Adds the forwards configuration.
     *
     * @access protected
     * @param array $value
     */
    protected function addForwardsConfig($value)
    {
        $this->_forwardsConfig = $value;
    }

    /**
     * Returns the <i>ZNF_Action_ActionForward</i> object defining how forwarding to the specified logical name should be handled.
     *
     * This is performed by checking the application configuration for the
     * specified forwarding configuration. If no forwarding configuration can
     * be found returns <i>null</i>.
     *
     * @access public
     * @param string $name The result of the <i>ZNF_Action_Action->execute()</i> method
     * @return ZNF_Action_ActionForward
     */
    public function findForward($name)
    {
        if ($name && is_array($this->_forwardsConfig) && array_key_exists($name, $this->_forwardsConfig)) {
            return new ZNF_Action_ActionForward($this->_forwardsConfig[$name]);
        }

        if ($name && is_array($this->_globalForwardsConfig) && array_key_exists($name, $this->_globalForwardsConfig)) {
            return new ZNF_Action_ActionForward($this->_globalForwardsConfig[$name]);
        }

        return null;
    }

    /**
     * Destroys the <i>ZNF_Action_ActionMapping</i> object.
     *
     * @access public
     */
    public function __destruct()
    {
    }

}

/**
 * <i>ZNF_Action_ActionMappingException</i> is the exception type for the <i>ZNF_Action_ActionMapping</i> class.
 *
 * <i>ZNF_Action_ActionMappingException</i> extends the <i>Exception</i> class of PHP5.
 *
 * @access     public
 * @package    ZNF
 * @subpackage Action
 * @author     Alessandro Rossini <http://www.alessandrorossini.org>
 * @author     Graziano Liberati <http://www.liberati.org>
 * @copyright  2004-2007 The ZNF Development Team
 * @license    LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
 * @version    SVN $Id: ActionMapping.php 43 2007-06-26 23:36:35Z aronnax $
 * @since      Release 0.5.0
 * @link       http://www.zeronotice.org
 */
class ZNF_Action_ActionMappingException extends Exception
{
}

?>
